package cn.tedu.kcircle.attachment.adapter.rpc;

import cn.tedu.kcircle.attachment.adapter.converter.AttachmentAdapterConverter;
import cn.tedu.kcircle.attachment.api.rpc.AttachmentRpcApi;
import cn.tedu.kcircle.attachment.protocol.dto.UploadRequestDTO;
import cn.tedu.kcircle.attachment.protocol.dto.UploadResultDTO;
import cn.tedu.kcircle.attachment.repository.persist.AttachmentRepository;
import cn.tedu.kcircle.attachment.service.AttachmentService;
import cn.tedu.kcircle.attachment.service.bo.UploadRequestBO;
import cn.tedu.kcircle.attachment.service.bo.UploadResultBO;
import lombok.AllArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@Service
@AllArgsConstructor
public class AttachmentRpcApiImpl implements AttachmentRpcApi {
    private AttachmentService attachmentService;
    private AttachmentAdapterConverter converter;

    @Override
    public UploadResultDTO upload(UploadRequestDTO uploadRequestDTO) {
        UploadRequestBO uploadRequestBO = converter.dto2BO(uploadRequestDTO);
        UploadResultBO uploadResultBO = attachmentService.uploadFile(uploadRequestBO);
        return converter.bo2DTO(uploadResultBO);
    }
}
